package com.ruoyi.mall.controller;

import java.util.List;

import com.ruoyi.mall.domain.MallMemberUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallTimeGoodsPool;
import com.ruoyi.mall.service.IMallTimeGoodsPoolService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 抢购商品池Controller
 *
 * @author ruoyi
 * @date 2022-03-16
 */
@RestController
@RequestMapping("/mall/mallTimeGoodsPool")
public class MallTimeGoodsPoolController extends BaseController
{
    @Autowired
    private IMallTimeGoodsPoolService mallTimeGoodsPoolService;

    /**
     * 查询抢购商品池列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeGoodsPool:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallTimeGoodsPool mallTimeGoodsPool)
    {
        startPage();
        List<MallTimeGoodsPool> list = mallTimeGoodsPoolService.selectMallTimeGoodsPoolList(mallTimeGoodsPool);
        return getDataTable(list);
    }

    /**
     * 导出抢购商品池列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeGoodsPool:export')")
    @Log(title = "抢购商品池", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallTimeGoodsPool mallTimeGoodsPool)
    {
        List<MallTimeGoodsPool> list = mallTimeGoodsPoolService.selectMallTimeGoodsPoolList(mallTimeGoodsPool);
        ExcelUtil<MallTimeGoodsPool> util = new ExcelUtil<MallTimeGoodsPool>(MallTimeGoodsPool.class);
        return util.exportExcel(list, "抢购商品池数据");
    }

    /**
     * 获取抢购商品池详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeGoodsPool:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallTimeGoodsPoolService.selectMallTimeGoodsPoolById(id));
    }

    /**
     * 新增抢购商品池
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeGoodsPool:add')")
    @Log(title = "抢购商品池", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallTimeGoodsPool mallTimeGoodsPool)
    {
        return toAjax(mallTimeGoodsPoolService.insertMallTimeGoodsPool(mallTimeGoodsPool));
    }

    /**
     * 修改抢购商品池
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeGoodsPool:edit')")
    @Log(title = "抢购商品池", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallTimeGoodsPool mallTimeGoodsPool)
    {
        return toAjax(mallTimeGoodsPoolService.updateMallTimeGoodsPool(mallTimeGoodsPool));
    }

    /**
     * 删除抢购商品池
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeGoodsPool:remove')")
    @Log(title = "抢购商品池", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallTimeGoodsPoolService.deleteMallTimeGoodsPoolByIds(ids));
    }

    /**
     * 查询商品池列表
     */
    @GetMapping("/getGoodsPoolList")
    public AjaxResult getGoodsPoolList(MallTimeGoodsPool mallTimeGoodsPool)
    {
        List<MallTimeGoodsPool> list = mallTimeGoodsPoolService.selectMallTimeGoodsPoolList(mallTimeGoodsPool);
        return AjaxResult.success(list);
    }
}
